package com.le.tester.webpage.secKill.controller;

import com.le.tester.common.ServerResponse;
import com.le.tester.dto.OrderDetailDto;
import com.le.tester.entity.OrderInfo;
import com.le.tester.webpage.secKill.service.OrderService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 描述：订单控制层
 */
@Controller
@RequestMapping("/order/")
public class OrderController {

    private static final Logger LOG = LoggerFactory.getLogger(OrderController.class);

    @Autowired
    private OrderService orderService;

    @ResponseBody
    @RequestMapping("detail")
    public ServerResponse<OrderInfo> getOrderDetail(@RequestParam Long orderId) {
        //登录校验，参数校验；省略

        //根据订单id获取订单详细信息
        try {
            OrderInfo order = orderService.getOrderDetail(orderId);
            //获取商品id
            return ServerResponse.createBySuccess(order);
        } catch (Exception e) {
            LOG.info("根据订单id获取信息详情异常：{}", e.getMessage());
            return ServerResponse.createByErrorMessage(e.getMessage());
        }

    }
}
